package com.dahuiji.tool;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class SendMail {
	public SendMail() {
	}

	public void send(String smtp, String userEmail, String userEmailPassword,
			String to, String Subject, String Msg) {
		SimpleEmail email = new SimpleEmail();
		email.setTLS(true);
		email.setHostName(smtp);
		email.setAuthentication(userEmail, userEmailPassword);

		try {
			email.addTo(to);
			email.setFrom(userEmail); // 我方

			email.setSubject(Subject); // 标题

			email.setCharset("utf-8"); // 设置Charset

			email.setMsg(Msg); // 内容

			email.send();

		} catch (EmailException e) {
			e.printStackTrace();
		}
	}

}
